package com.itheima.mapper;

import com.itheima.entity.Clazz;
import com.itheima.entity.ClazzQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClazzMapper {

    List<Clazz> list(ClazzQueryParam cqp);

    List<Clazz> list2(ClazzQueryParam cqp);



//    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into clazz values(null, #{name}, #{room}, #{beginDate}, #{endDate}, #{masterId}, #{subject}," +
            " #{createTime}, #{updateTime}) ")
    void insert(Clazz clazz);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Select("select * from clazz where id=#{id}")
    Clazz findById(Integer id);

    @Delete("delete from clazz where id = #{id};")
    void deleteById(Integer id);

    void update(Clazz clazz);

    @Select("select c.* , e.name  masterName from clazz c left join emp e on c.master_id=e.id")
    List<Clazz> allList();
}
